﻿using System.Collections.Generic;
using Core.Library;

namespace DataObject.Article
{
    public class ArticleController
    {        
        /***************************************
        = Back End
        -------------------------------------- */
        public static int Article_Create(ArticleObject o)
        {
            return ArticleDAL.Article_Create(o);
        }

        public static void Article_Update(ArticleObject o)
        {
            ArticleDAL.Article_Update(o);
        }

        public static void Article_Delete(int id)
        {
            ArticleDAL.Article_Delete(id);
        }

        public static ArticleObject Article_GetById(int id)
        {
            return ObjectHelper.FillObject<ArticleObject>(ArticleDAL.Article_GetById(id));
        }

        public static List<ArticleObject> Article_GetListSearch(int categoryId, string keyword, int status, int pageIndex, int pageSize, ref int totalRecords)
        {
            return ObjectHelper.FillCollection<ArticleObject>(
                    ArticleDAL.Article_GetListSearch(categoryId, keyword, status, pageIndex, pageSize, ref totalRecords));
        }
        
        public static int Article_GetStatistic(int adminUserId, int status)
        {
            return ArticleDAL.Article_GetStatistic(adminUserId, status);
        }

        public static void Article_Update_Status(int adminUserId, int id, int status)
        {
            ArticleDAL.Article_Update_Status(adminUserId, id, status);
        }

        /***************************************
        = Front End
        -------------------------------------- */
        public static List<ArticleObject> Article_GetListByCategory_Static(int categoryId)
        {
            return ObjectHelper.FillCollection<ArticleObject>(ArticleDAL.Article_GetListByCategory_Static(categoryId));
        }

        public static List<ArticleObject> Article_GetListByCategoryId_Parent(int categoryId)
        {
            return ObjectHelper.FillCollection<ArticleObject>(ArticleDAL.Article_GetListByCategoryId_Parent(categoryId));
        }

        public static List<ArticleObject> Article_GetListByCategoryId(int categoryId)
        {
            return ObjectHelper.FillCollection<ArticleObject>(ArticleDAL.Article_GetListByCategoryId(categoryId));
        }

        public static List<ArticleObject> Article_GetTopHighlight(int count)
        {
            return ObjectHelper.FillCollection<ArticleObject>(ArticleDAL.Article_GetTopHighlight(count));
        }

        public static List<ArticleObject> Article_GetListOrderByPublishOn(int categoryId, int pageIndex, int pageSize, ref int totalRecords)
        {        
            var data = ObjectHelper.FillCollection<ArticleObject>(
                        ArticleDAL.Article_GetListOrderByPublishOn(categoryId, pageIndex, pageSize, ref totalRecords));
            return data;            
        }
    }
}
